import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/view_model/my/customization_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';

import '../button_widget.dart';

///筛选组件
class CustomizationScreenWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    CustomizationViewModel customizationViewModel = Provider.of(context);

    return Visibility(
      visible: customizationViewModel.screenBool,
      child: Column(
        children: <Widget>[
          Container(
            padding: EdgeInsets.only(
                top: ScreenUtil().setWidth(34),
                left: ScreenUtil().setWidth(34),
                right: ScreenUtil().setWidth(34)),
            color: Colors.white,
            alignment: Alignment.centerLeft,
            child: Text("年级", style: TextStyles.textDark30),
          ),
          _gridViewWidget(),
          Container(
            padding: EdgeInsets.only(
                left: ScreenUtil().setWidth(34),
                right: ScreenUtil().setWidth(34)),
            color: Colors.white,
            alignment: Alignment.centerLeft,
            child: Text("科目", style: TextStyles.textDark30),
          ),
          _gridViewWidget(),
          Container(
            color: Colors.white,
            child: Row(
              children: <Widget>[
                Expanded(
                  child: ButtonWidget().rectangleButtonWidget(
                      buttonName: "重置",
                      bgColor: Colors.white,
                      textStyle: TextStyles.textDark43,
                      onPressed: () {
                        customizationViewModel.screenOnTap();
                      }),
                ),
                Expanded(
                  child: ButtonWidget().rectangleButtonWidget(
                      buttonName: "确定", onPressed: () {
                    customizationViewModel.screenOnTap();

                  }),
                )
              ],
            ),
          ),
          Expanded(child: GestureDetector(child: Container(color: Colors.black26),onTap: customizationViewModel.screenOnTap,)),
        ],
      ),
    );
  }

  Widget _gridViewWidget() {
    return Container(
      color: Colors.white,
      child: GridView.builder(
        shrinkWrap: true,
        itemCount: 10,
        physics: NeverScrollableScrollPhysics(),
        padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 5,
          mainAxisSpacing: ScreenUtil().setWidth(35),
          crossAxisSpacing: ScreenUtil().setWidth(35),
          childAspectRatio: ScreenUtil().setHeight(70) / 10,
        ),
        itemBuilder: (context, index) {
          return Container(
            alignment: Alignment.center,
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius:
                    BorderRadius.circular(ScreenUtil().setHeight(70) / 2),
                border: Border.all(color: Colors.grey, width: 0.5)),
            child: Text(
              "语文",
              style: TextStyles.textDark28,
            ),
          );
        },
      ),
    );
  }
}
